<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="maven,gitlab,nexus,gitflow,jgit-flow," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="前文回顾前文讲述了IT自动化生产线上的核心工具开源Git服务器实现Gitlab。本文将以前述两篇文章为基础，以代码工程示例，将Maven和Gitlab进行整合，实现生产线上的第一次自动化衔接。
Git-Flow在实际示例之前，我们先回顾一下著名的Git-Flow模型。该模型来自Vincent Driessen’s branching model

Git-Flow模型是一个动态可伸缩的模型，你可以">
<meta property="og:type" content="article">
<meta property="og:title" content="IT自动化(5)——持续开发中流程管理gitflow">
<meta property="og:url" content="http://chrisrc.me/2015/08/14/autoit-maven-git-jgit-flow/index.html">
<meta property="og:site_name" content="山中，山外与俯瞰">
<meta property="og:description" content="前文回顾前文讲述了IT自动化生产线上的核心工具开源Git服务器实现Gitlab。本文将以前述两篇文章为基础，以代码工程示例，将Maven和Gitlab进行整合，实现生产线上的第一次自动化衔接。
Git-Flow在实际示例之前，我们先回顾一下著名的Git-Flow模型。该模型来自Vincent Driessen’s branching model

Git-Flow模型是一个动态可伸缩的模型，你可以">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow.gif">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_project_dev.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_pre.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_pre2.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_pre3.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_pre4.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_start.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_start_2.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_start_3.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_finish.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_gitflow_release_finish2.png">
<meta property="og:updated_time" content="2016-12-17T03:42:16.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="IT自动化(5)——持续开发中流程管理gitflow">
<meta name="twitter:description" content="前文回顾前文讲述了IT自动化生产线上的核心工具开源Git服务器实现Gitlab。本文将以前述两篇文章为基础，以代码工程示例，将Maven和Gitlab进行整合，实现生产线上的第一次自动化衔接。
Git-Flow在实际示例之前，我们先回顾一下著名的Git-Flow模型。该模型来自Vincent Driessen’s branching model

Git-Flow模型是一个动态可伸缩的模型，你可以">
<meta name="twitter:image" content="http://chrisrc.me/images/autoit_gitflow.gif">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://chrisrc.me/2015/08/14/autoit-maven-git-jgit-flow/"/>





  <title> IT自动化(5)——持续开发中流程管理gitflow | 山中，山外与俯瞰 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">山中，山外与俯瞰</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">一次永不停止的探索之旅</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-dcos">
          <a href="/dcos" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            DC/OS
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="st-search-show-outputs">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'R9GcmhBwxpsAGLNCsquZ','2.0.0');
</script>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://chrisrc.me/2015/08/14/autoit-maven-git-jgit-flow/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="chrisrc">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="山中，山外与俯瞰">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="山中，山外与俯瞰" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                IT自动化(5)——持续开发中流程管理gitflow
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2015-08-14T10:26:21+08:00">
                2015-08-14
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IT自动化/" itemprop="url" rel="index">
                    <span itemprop="name">IT自动化</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <a href="/2015/08/14/autoit-maven-git-jgit-flow/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/08/14/autoit-maven-git-jgit-flow/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="前文回顾"><a href="#前文回顾" class="headerlink" title="前文回顾"></a>前文回顾</h2><p><a href="/2015-08-13/autoit-gitlab">前文</a>讲述了IT自动化生产线上的核心工具开源Git服务器实现Gitlab。本文将以前述两篇文章为基础，以代码工程示例，将Maven和Gitlab进行整合，实现生产线上<br>的第一次自动化衔接。</p>
<h2 id="Git-Flow"><a href="#Git-Flow" class="headerlink" title="Git-Flow"></a>Git-Flow</h2><p>在实际示例之前，我们先回顾一下著名的Git-Flow模型。该模型来自<a href="http://nvie.com/posts/a-successful-git-branching-model/" target="_blank" rel="external">Vincent Driessen’s branching model</a></p>
<p><img src="/images/autoit_gitflow.gif" alt="Git-Flow"></p>
<p>Git-Flow模型是一个动态可伸缩的模型，你可以根据项目的复杂度灵活的缩减或增加流程。其中，最基本最简单的流程是就是develop和master，分别对应着<br>开发和发布两个过程。</p>
<p>关于Git-Flow的详细指南，请参考<a href="http://blog.jobbole.com/76867/" target="_blank" rel="external">Git工作流指南：Gitflow工作流</a>。</p>
<h2 id="jgit-flow"><a href="#jgit-flow" class="headerlink" title="jgit-flow"></a>jgit-flow</h2><p>在基于Maven管理的项目中，<code>maven-release-plugin</code>能够满足通常的项目发布过程，但是 <strong>maven-release-plugin</strong> 最初用在基于CVS/SVN的发布过程，为了<br>向后兼容，该插件很难满足基于Git-Flow模型的发布管理。</p>
<p>Atlassian公司开源了<a href="https://bitbucket.org/atlassian/jgit-flow" target="_blank" rel="external">Maven JGit-Flow Plugin</a>，该插件基于<a href="http://eclipse.org/jgit/" target="_blank" rel="external">JGit</a>实现了<br>Vincent Driessen的<code>branching model</code>。</p>
<h3 id="jgit-flow的功能"><a href="#jgit-flow的功能" class="headerlink" title="jgit-flow的功能"></a>jgit-flow的功能</h3><ul>
<li><a href="https://bitbucket.org/atlassian/jgit-flow/wiki/goals/release-start" target="_blank" rel="external">release-start</a> - 创建一个<em>发布分支</em>，使用<em>发布版本号</em>更新工程中的POM版本  </li>
<li><a href="https://bitbucket.org/atlassian/jgit-flow/wiki/goals/release-finish" target="_blank" rel="external">release-finish</a> - 执行一次Maven编译（deploy或install），合并release-start过程中创建的发布分支，使用<em>开发版本号</em>更新工程中的POM版本  </li>
<li><a href="https://bitbucket.org/atlassian/jgit-flow/wiki/goals/hotfix-start" target="_blank" rel="external">hotfix-start</a> - 创建一个<em>补丁分支</em>，使用<em>补丁版本号</em>更新工程中的POM版本</li>
<li><a href="https://bitbucket.org/atlassian/jgit-flow/wiki/goals/hotfix-finish" target="_blank" rel="external">hotfix-finish</a> - 执行一次Maven编译（deploy或install），合并hotfix-start过程中创建的补丁分支，使用<em>之前的版本号</em>更新工程中的POM版本  </li>
<li><a href="https://bitbucket.org/atlassian/jgit-flow/wiki/goals/feature-start" target="_blank" rel="external">feature-start</a> - 创建一个<em>功能分支</em></li>
<li><a href="https://bitbucket.org/atlassian/jgit-flow/wiki/goals/feature-finish" target="_blank" rel="external">feature-finish</a> - 合并一个<em>功能分支</em></li>
<li><a href="https://bitbucket.org/atlassian/jgit-flow/wiki/goals/build-number" target="_blank" rel="external">build-number</a> - 通过添加一个编译编号（-buildX， X通过<code>buildNumber</code>属性来指定）来更新当前分支中的POM版本</li>
</ul>
<h3 id="使用jgit-flow"><a href="#使用jgit-flow" class="headerlink" title="使用jgit-flow"></a>使用jgit-flow</h3><p>通过在pom.xml中添加如下配置来使用jgit-flow：  </p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">build</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>external.atlassian.jgitflow<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>jgitflow-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-m5.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></div><div class="line">               <span class="tag">&lt;<span class="name">flowInitContext</span>&gt;</span></div><div class="line">                 <span class="tag">&lt;<span class="name">masterBranchName</span>&gt;</span>frankenstein<span class="tag">&lt;/<span class="name">masterBranchName</span>&gt;</span></div><div class="line">                 <span class="tag">&lt;<span class="name">developBranchName</span>&gt;</span>development<span class="tag">&lt;/<span class="name">developBranchName</span>&gt;</span></div><div class="line">                 <span class="tag">&lt;<span class="name">featureBranchPrefix</span>&gt;</span>feature-<span class="tag">&lt;/<span class="name">featureBranchPrefix</span>&gt;</span></div><div class="line">                 <span class="tag">&lt;<span class="name">releaseBranchPrefix</span>&gt;</span>release-<span class="tag">&lt;/<span class="name">releaseBranchPrefix</span>&gt;</span></div><div class="line">                 <span class="tag">&lt;<span class="name">hotfixBranchPrefix</span>&gt;</span>hotfix-<span class="tag">&lt;/<span class="name">hotfixBranchPrefix</span>&gt;</span></div><div class="line">                 <span class="tag">&lt;<span class="name">versionTagPrefix</span>&gt;</span>blither-<span class="tag">&lt;/<span class="name">versionTagPrefix</span>&gt;</span></div><div class="line">               <span class="tag">&lt;/<span class="name">flowInitContext</span>&gt;</span></div><div class="line">               <span class="tag">&lt;<span class="name">username</span>&gt;</span>MY_USER<span class="tag">&lt;/<span class="name">username</span>&gt;</span></div><div class="line">               <span class="tag">&lt;<span class="name">password</span>&gt;</span>MY_PW<span class="tag">&lt;/<span class="name">password</span>&gt;</span></div><div class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">build</span>&gt;</span></div></pre></td></tr></table></figure>
<p>常用配置参数如下表所示，更详细的配置请参考上述jgit-flow的goals。  </p>
<table>
<thead>
<tr>
<th>参数</th>
<th>注释</th>
</tr>
</thead>
<tbody>
<tr>
<td>allowSnapshots</td>
<td>是否允许SNAPSHOT依赖，默认值为false</td>
</tr>
<tr>
<td>autoVersionSubmodules</td>
<td>是否允许为子模块自动设定父模块的版本，默认值为false，执行时会逐个模块提示</td>
</tr>
<tr>
<td>pushReleases</td>
<td>是否将发布分支推送到远端服务器，默认值为false</td>
</tr>
<tr>
<td>keepBranch</td>
<td>是否在发布完成后还保留发布分支，如果值为false将删除分支，默认值为false</td>
</tr>
<tr>
<td>noDeploy</td>
<td>是否执行maven deploy，默认值为false，设为true时，执行maven的install目标</td>
</tr>
</tbody>
</table>
<h2 id="版本发布示例"><a href="#版本发布示例" class="headerlink" title="版本发布示例"></a>版本发布示例</h2><p>下面我们以<a href="https://github.com/christtrc/greeter-osgi-example" target="_blank" rel="external">greeter-osgi-example</a>代码工程来演示基于Maven管理的项目采用Git-Flow发布版本到Gitlab上的过程。</p>
<h3 id="示例工程"><a href="#示例工程" class="headerlink" title="示例工程"></a>示例工程</h3><p>关于本文示例工程的详细介绍，请参考前述博文 <strong>Apache Karaf构建动态模块化应用</strong> 系列。示例工程中的<code>jgit-flow</code>插件配置如下所示：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>external.atlassian.jgitflow<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>jgitflow-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-m5.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">autoVersionSubmodules</span>&gt;</span>true<span class="tag">&lt;/<span class="name">autoVersionSubmodules</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">pushReleases</span>&gt;</span>true<span class="tag">&lt;/<span class="name">pushReleases</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">keepBranch</span>&gt;</span>false<span class="tag">&lt;/<span class="name">keepBranch</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">noDeploy</span>&gt;</span>true<span class="tag">&lt;/<span class="name">noDeploy</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">flowInitContext</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">developBranchName</span>&gt;</span>dev<span class="tag">&lt;/<span class="name">developBranchName</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">versionTagPrefix</span>&gt;</span>release/<span class="tag">&lt;/<span class="name">versionTagPrefix</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">flowInitContext</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></div></pre></td></tr></table></figure></p>
<p>在上述配置中，我们通过<code>autoVersionSubmodules</code>配置在发布时仅需确认一次版本号，通过<code>pushReleases</code>将发布分支推送到Gitlab，<br>通过<code>keepBranch</code>在发布完成后删除分支标记，通过<code>noDeploy</code>取消执行<code>release-finish</code>目标过程中同时向远端Nexus仓库部署发布的构件（因为<br>本工程为示例工程，所以简化了此步骤。在实际开发过程中，推荐将发布构件上传到Nexus仓库，供其它项目使用）。</p>
<h3 id="开发流程"><a href="#开发流程" class="headerlink" title="开发流程"></a>开发流程</h3><p><strong>首先</strong> 创建Git仓库，准备工程初始环境，提交到Git仓库作为master基线。如下图所示：</p>
<p><img src="/images/autoit_gitflow_project_dev.png" alt="jgitflow:project dev"></p>
<p>冻结master分支（Project—Settings—-Protected Branches），仅将权限分配给负责发布的人员。</p>
<p>创建<code>dev</code>分支，团队所有人员的开发工作围绕此分支进行。为了产品的快速开发迭代，测试工作可以在<code>dev</code>分支上进行，具体请参考<br>后续文章中通过Jenkins与Gitlab集成并自动触发测试版本的构建的介绍。当前我们关注正式版本的发布流程。</p>
<p><img src="/images/autoit_gitflow_release_pre.png" alt="jgitflow:project merge"></p>
<p>待开发工作进行到一定阶段，可以发布一个版本时，将<code>dev</code>分支合并到master分支。这一步工作既可以在命令行，也可以通过客户端工具，最<br>方便的是Gitlab直接提供了<code>merge request</code>功能：</p>
<p><img src="/images/autoit_gitflow_release_pre2.png" alt="jgitflow:project merge"></p>
<p><img src="/images/autoit_gitflow_release_pre3.png" alt="jgitflow:project merge"></p>
<p><img src="/images/autoit_gitflow_release_pre4.png" alt="jgitflow:project merge"></p>
<p>通过<code>Accept Merge Request</code>，合并<code>dev</code>分支到<code>master</code>分支，发布工作准备就绪。</p>
<h3 id="Start-Release"><a href="#Start-Release" class="headerlink" title="Start Release"></a>Start Release</h3><p>克隆一个最新的版本（<strong>推荐</strong>），否则，<strong>在执行下述命令前，请将本地工程提交并push到远程Gitlab服务器，并同步代码到本地</strong>，进入到工程目录，<br>在命令行执行如下命令：  </p>
<blockquote>
<p><code>mvn jgitflow:release-start</code></p>
</blockquote>
<p>如果工程准备就绪，jgitflow会分析工程结构，确认当前开发版本号，并提示用户确认要正式发布的版本号，如下图所示：</p>
<p><img src="/images/autoit_gitflow_release_start.png" alt="jgitflow:release-start"></p>
<p>在确认发布版本号之后，jgitflow会自动在发布版本号的基础上加1，作为下一个开发版本号。继续确认，jgitflow将提示输入访问Gitlab服务器<br>的用户凭据（可以在Plugin配置参数里设定）。输入凭据后，release-start的过程结束。</p>
<p><img src="/images/autoit_gitflow_release_start_2.png" alt="jgitflow:release-start"></p>
<p>此时，本地和远端Gitlab均创建一个名为<code>release/1.0.0</code>的分支，远端是否创建可通过配置参数控制。</p>
<p><img src="/images/autoit_gitflow_release_start_3.png" alt="jgitflow:release-start"></p>
<h3 id="Finish-Release"><a href="#Finish-Release" class="headerlink" title="Finish Release"></a>Finish Release</h3><p>在<code>release-start</code>目标成功执行后，可以启动<code>release-finish</code>来完成最终的版本发布。首先在工程目录中，执行如下命令：  </p>
<blockquote>
<p><code>mvn jgitflow:release-finish</code></p>
</blockquote>
<p><img src="/images/autoit_gitflow_release_finish.png" alt="jgitflow:release-finish"></p>
<p>待命令成功执行后，版本发布完成。我们可以登录到Gitlab上查看发布版本后生成的新的标记Tag（<code>release/1.0.0</code>）:  </p>
<p><img src="/images/autoit_gitflow_release_finish2.png" alt="jgitflow:release-finish"></p>
<h2 id="自动化是如何实现的"><a href="#自动化是如何实现的" class="headerlink" title="自动化是如何实现的"></a>自动化是如何实现的</h2><p>在上述操作过程中，我们简要分了三个阶段，即 <strong>日常开发阶段</strong>， <strong>分支合并阶段</strong> 和 最终的 <strong>发布阶段</strong>。</p>
<p>日常开发阶段是开发团队<br>的日常工作，也是我们IT自动化过程中工作的起点， 分支合并阶段是有项目管理人员控制的，实际上也是日常开发的一部分， 发布阶段，我们<br>通过两个maven命令就完成了项目的版本发布。</p>
<p>此处的发布仍然是手工操作，在后续讲到Jenkins时，我们通过与Jenkins集成，来实现版本的自动发布。</p>
<h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><ul>
<li>Maven为工程的自动化构建提供了支撑， Gitlab实现了源代码及版本管理，<code>jgitflow</code>插件将两者结合起来，使得工作过程得以自动<br>衔接。</li>
<li>在下一篇文章中，我们将开始介绍自动化构建过程中的另一个最重要的工具——Jenkins。</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/maven/" rel="tag"># maven</a>
          
            <a href="/tags/gitlab/" rel="tag"># gitlab</a>
          
            <a href="/tags/nexus/" rel="tag"># nexus</a>
          
            <a href="/tags/gitflow/" rel="tag"># gitflow</a>
          
            <a href="/tags/jgit-flow/" rel="tag"># jgit-flow</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/08/13/autoit-gitlab/" rel="next" title="IT自动化(4)——持续开发的代码管理中心Gitlab">
                <i class="fa fa-chevron-left"></i> IT自动化(4)——持续开发的代码管理中心Gitlab
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/08/15/autoit-jenkins/" rel="prev" title="IT自动化(6)——生产线上的调度和控制中心Jenkins">
                IT自动化(6)——生产线上的调度和控制中心Jenkins <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2015/08/14/autoit-maven-git-jgit-flow/"
     data-title="IT自动化(5)——持续开发中流程管理gitflow"
     data-content=""
     data-url="http://chrisrc.me/2015/08/14/autoit-maven-git-jgit-flow/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/08/14/autoit-maven-git-jgit-flow/"
           data-title="IT自动化(5)——持续开发中流程管理gitflow" data-url="http://chrisrc.me/2015/08/14/autoit-maven-git-jgit-flow/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="chrisrc" />
          <p class="site-author-name" itemprop="name">chrisrc</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">69</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">21</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">162</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/christtrc" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/chrisrc" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前文回顾"><span class="nav-number">1.</span> <span class="nav-text">前文回顾</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Git-Flow"><span class="nav-number">2.</span> <span class="nav-text">Git-Flow</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#jgit-flow"><span class="nav-number">3.</span> <span class="nav-text">jgit-flow</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#jgit-flow的功能"><span class="nav-number">3.1.</span> <span class="nav-text">jgit-flow的功能</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用jgit-flow"><span class="nav-number">3.2.</span> <span class="nav-text">使用jgit-flow</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#版本发布示例"><span class="nav-number">4.</span> <span class="nav-text">版本发布示例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#示例工程"><span class="nav-number">4.1.</span> <span class="nav-text">示例工程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#开发流程"><span class="nav-number">4.2.</span> <span class="nav-text">开发流程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Start-Release"><span class="nav-number">4.3.</span> <span class="nav-text">Start Release</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Finish-Release"><span class="nav-number">4.4.</span> <span class="nav-text">Finish Release</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#自动化是如何实现的"><span class="nav-number">5.</span> <span class="nav-text">自动化是如何实现的</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#结论"><span class="nav-number">6.</span> <span class="nav-text">结论</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">
     
      <a href="mailto:chrisrc@qq.com">chrisrc</a> 
    
  </span>
  <span class="author"> &nbsp; QQ: 58122705 </span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"chrisrc"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  








  
  

  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
<script>
(function(){
   var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04":"https://jspassport.ssl.qhimg.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04";
   document.write('<script src="' + src + '" id="sozz"><\/script>');
})();
</script>

  


</body>
</html>
